import Vue from 'vue'
import VueRouter from 'vue-router'


//注册全局组件  router-link   router-view
Vue.use(VueRouter)


// 1. 定义 (路由) 组件。
// 可以从其他文件 import 进来
// @--src

// 2. 定义路由
const routes = [{
		name: 'Home',
		path: '/home',
		redirect: '/'
	},
	{
		name: 'Home',
		path: '/',
		component: () => import('@/Home.vue'),
		children: [
			{
				name: 'User',
				path: '/user',
				component:() => import('@/views/User.vue'),
			},
			{
				path: '/role',
				component: () => import('@/views/Role.vue'),
			},
			{
				path: '/menu',
				component:  () => import('@/views/menu'),
			},
			{
				path: '/news',
				component:  () => import('@/views/news'),
				children: [{
					path: '/news/local',
					component:  () => import('@/views/news/Local'),
				}, {
					path: '/news/internation',
					component:  () => import('@/views/news/Internation')
				}]
			}

		]
	},
	{
		name: 'Login',
		path: '/login',
		component: () => import('@/Login.vue')
	},
	{
		path: '*',
		component: () => import('@/NotFound.vue')
	},



]

// 3. 创建 router 实例，然后传 `routes` 配置
// 你还可以传别的配置参数, 不过先这么简单着吧。

/**   
 * 
 
     Hash 
 *    http://127.0.0.1/#/user
 *    http://127.0.0.1/#/role
 *    http://127.0.0.1/#menu
 
     History
 *    http://127.0.0.1/user
 *    http://127.0.0.1/role
 *    http://127.0.0.1/menu
    
	
	VueRouter   --- Vue实例（根）
 */
const router = new VueRouter({
	// url 、
	// mode: 'history',
	mode: 'hash',
	routes // (缩写) 相当于 routes: routes
})

export default router